package com.woniuxy.controller;

import com.woniuxy.Service.IUserService;
import com.woniuxy.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author lg
 * @time 2020/07/09 19:44:25
 */
@Controller
@RequestMapping("users")
public class UserController {
     @Autowired
     private IUserService service;

     @ResponseBody
     @RequestMapping("save")
    public  void  save(@RequestBody User user){

         service.save (user);
     }

     @ResponseBody
    @RequestMapping("findAll")
    public List<User> findAll(){
          return service.find ();
     }

    @ResponseBody
    @RequestMapping("delete")
    public void delete(@RequestBody User user){
         service.delete (user.getUid ());
    }
    @ResponseBody
    @RequestMapping("update")
    public void update(@RequestBody User user){
        service.update (user);
    }

}
